package myJs.myPkg

import jsext._

import scala.scalajs.js
import scala.language.implicitConversions
import scala.scalajs.js.JSConverters._
import jquery.JQuery


/**
 * Created by yz on 2019/3/14
 */

@js.native
trait BootstrapValidator extends js.Object {

  def defaultSubmit(): js.Any = js.native

  def getFieldElements(field: String): JQuery = js.native

  def updateMessage(field: String, validator: String, message: String): js.Any = js.native

  def updateMessage(jq: JQuery, validator: String, message: String): js.Any = js.native

  def updateStatus(field: String, status: String, validator: String): js.Any = js.native

  def updateStatus(field: String, status: String): js.Any = js.native

  def updateStatus(jq: JQuery, status: String, validator: String): js.Any = js.native

  def updateStatus(jq: JQuery, status: String): BootstrapValidator = js.native

  def addField(jq: JQuery): BootstrapValidator = js.native

  def removeField(jq: JQuery): BootstrapValidator = js.native

  def enableFieldValidators(field: String, enabled: Boolean): BootstrapValidator = js.native

  def isValid(): Boolean = js.native

  def isValidField(field: String): Boolean = js.native

  def validate(): BootstrapValidator = js.native

  def resetForm(resetFormData: Boolean): BootstrapValidator = js.native

  def revalidateField(field: String): BootstrapValidator = js.native

  def revalidateField(fields: String*): BootstrapValidator = js.native

  def revalidateField(jq: JQuery): BootstrapValidator = js.native

  def getInvalidFields(): js.Array[JQuery] = js.native

}

@js.native
trait BootstrapValidatorJQuery extends js.Object {

  def bootstrapValidator(dict: js.Dictionary[js.Any]): JQuery = scalajs.js.native

}

trait BootstrapValidatorJQueryImplicits {
  implicit def implicitBootstrapValidatorJQuery(jq: JQuery): BootstrapValidatorJQuery = {
    jq.asInstanceOf[BootstrapValidatorJQuery]
  }
}
